//
//  ICMessageHelper.h
//  ICome
//
//  Created by ENN on 16/4/7.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ICGtasksModel.h"
#import "ICNotify.h"
#import "ICCollectionModel.h"
#import "ICHeaderFile.h"

@class ICMessageFrame;
@class ICMessage;
@class ICMessageModel;
@class ICChnModel;

typedef void(^Finish)(ICMessageFrame *messageF);

@interface ICMessageHelper : NSObject

// 接收的消息 统一入口 存储 根据消息体进行存储
+ (void)messageTypeWithMessage:(NSDictionary *)dic
                      finished:(Finish)finished;

// 发送的消息  统一出口 拼装成字典 通过tcp发送消息
+ (NSDictionary *)createSendParamWithMessage:(ICMessage *)message;

/**
 *  创建一条本地消息
 *
 *  @param type    消息类型
 *  @param content 文本消息内容
 *  @param path    图片音频本地路径
 *
 *  @return 一条消息的ICMessageFrame
 */
+ (ICMessageFrame *)createMessageFrame:(NSString *)type
                               content:(NSString *)content
                                  path:(NSString *)path
                                  from:(NSString *)from
                                    to:(NSString *)to
                                   lnk:(NSString *)lnk
                               fileKey:(NSString *)fileKey
                              isSender:(BOOL)isSender
              receivedSenderByYourself:(BOOL)receivedSenderByYourself;

/**
 *  创建一条发送消息
 *
 *  @param type    消息类型
 *  @param content 消息文本内容，其它类型的类型名称:[图片]
 *  @param fileKey 音频文件的fileKey
 *  @param from    发送者
 *  @param to      接收者
 *  @param lnk     连接地址URL,图片格式,文件名称 （目前没用到）
 *  @param status  消息状态 （目前没用到）
 *
 *  @return 发送的消息
 */
+ (ICMessage *)createSendMessageF:(ICMessageFrame *)messageF
                          Message:(NSString *)type
                          content:(NSString *)content
                          fileKey:(NSString *)fileKey
                             from:(NSString *)from
                               to:(NSString *)to
                              lnk:(NSString *)lnk
                           status:(NSString *)status;
// 创建时间消息
+ (ICMessageFrame *)createTimeMessageFrame:(NSString *)type
                                   content:(NSString *)content
                                      path:(NSString *)path
                                      from:(NSString *)from
                                        to:(NSString *)to
                                   fileKey:(NSString *)fileKey
                                  isSender:(BOOL)isSender
                  receivedSenderByYourself:(BOOL)receivedSenderByYourself;

// 创建收藏消息
+ (NSDictionary *)createCollectMessage:(NSString *)type
                                   eId:(NSString *)eId
                                   gId:(NSString *)gId
                               photoId:(NSString *)photoId
                                 msgId:(NSString *)msgId
                                 title:(NSString *)title
                                   txt:(NSString *)txt
                                   key:(NSString *)key
                                   lnk:(NSString *)lnk;

// 视频
+ (void)receivedVideoMessage:(NSDictionary *)dic
                      finish:(Finish)finish
    receivedSenderByYourself:(BOOL)receivedSenderByYourself
                    progress:(void(^)(NSProgress *pro))progress;

// message 转代办 message
+ (ICGtasksModel *)getGtasksModelWith:(ICMessage *)message;
// message 转精灵 message
+ (ICChnModel *)getChnModelModelWith:(ICMessage *)message;
// message 转通知 message
+ (ICNotify *)getNotifyModelModelWith:(ICMessage *)message;


// 获得lastUpdate
+ (NSNumber *)getLastUpdate;

// 设置lastUpdate
+ (void)setLastUpdate:(NSNumber *)lastUpdate;
+ (NSNumber *)getGroupInfoLastUpdate:(NSString *)gId;
+ (void)setGroupInfoLastUpdate:(NSNumber *)lastUpdate
                           gId:(NSString *)gId;
+ (NSNumber *)getDirectLastUpdate;
+ (void)setDirectLastUpdate:(NSNumber *)lastUpdate;

// 删除消息附件
+ (void)deleteMessage:(ICMessageModel *)messageModel;

// current message time
+ (NSInteger)currentMessageTime;

// time format
+ (NSString *)timeFormatWithDate:(NSInteger)time;

+ (BOOL)isSenderBySelf:(NSString *)from;

// update group read
+ (void)updateGroupReadWithGroupId:(NSString *)gId;

+ (void)updateGroupReadWithGroupId:(NSString *)gId message:(NSNumber *)messageId;

// 语音已读
+ (void)voiceDidRead:(NSString *)gId
           messageId:(NSString *)msgId;

+ (NSString *)timeFormatWithDate2:(NSInteger)time;
+ (NSString *)timeFormatWithDate3:(NSInteger)time;
+ (NSString *)timeFormatWithDate4:(NSInteger)time;


+ (NSNumber *)fileType:(NSString *)type;
+ (UIImage *)allocationImage:(ICFileType)type;

+ (NSString *)timeDurationFormatter:(NSUInteger)duration;

+ (void)setServeGroupActive:(NSString *)gId;
// 是否为客服对应的小精灵组（客服服务的对象）
+ (BOOL)isServeRbtGroup:(NSString *)gId gType:(NSString *)gType;
// 是否是用户自己的小精灵组
+ (BOOL)isUserRbtGroup:(NSString *)gId gType:(NSString *)gType;

+(void)validateUrl:(NSString *)urlstr;
// @功能修改状态
+ (void)changeGroupStatus:(id)message;
// 坐标转换到窗口中的位置
+ (CGRect)photoFramInWindow:(UIButton *)photoView;
// 放大后的图片按钮在窗口中的位置
+ (CGRect)photoLargerInWindow:(UIButton *)photoView;
// 时间和内容的MD5串
+ (NSString *)localMessageId:(NSString *)content;

+ (CGFloat)getVoiceTimeLengthWithPath:(NSString *)path;
@end
